package com.example.easy.Controller;

import com.example.easy.Service.Impl.Test;
import com.example.easy.Tools.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.*;

@Scope("prototype")
@RestController
@Api(value = "Test", description = "测试")
public class TestContriller {
    @Autowired
    Test test;
    @ApiOperation(value = "写入redis", notes = "写入redis")
    @RequestMapping(value = "/set",method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object set(@RequestParam String key, @RequestParam String value){
        test.set(key,value);
        System.out.println("redis 写入");
        return ResultCode.SUCCESS.result();
    }
    @ApiOperation(value = "获得redis", notes = "获得redis")
    @RequestMapping(value = "/get",method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public String get(@RequestBody String key){
        System.out.println("redis 写入");
//        return ResultCode.SUCCESS.result(test.get(key));
        return "Success";
    }

    @RequestMapping("/test")
    public String testController(@RequestParam("testParams") String testParams) {
        return "Success!";
    }

}
